package ootexception;


import java.awt.*;
import java.awt.event.*;
import util.*;


public class ExceptionDialog extends Dialog implements ActionListener
{

    Button button_ok;
    Button button_help;
    String current_url;

  public ExceptionDialog(Frame parent,ExceptionHashNode enh)
  {
    super(parent);
    button_ok=new Button("Ok");
    button_help   =new Button("More info");
      button_ok.addActionListener(this);
    button_help.addActionListener(this);

    current_url=enh.url;

    TextArea msg_area=new TextArea("",0,0,TextArea.SCROLLBARS_NONE);
    msg_area.append(enh.msg+"\n");
    msg_area.setEditable(false);
    msg_area.setBackground(Color.white);

    setLayout(new BorderLayout());

    Panel panel=new Panel();
    panel.setLayout(new FlowLayout());
    panel.add(button_ok);
    panel.add(button_help);
    add(msg_area,"Center");
    add(panel,"South");

    setResizable(false);
    setModal(true);
 
    setSize(300,200);

  }

  public void update (Graphics g)
  {
    Debug.println("ExceptionDialog.update()");
  }

  public void paint (Graphics g)
  {
    Debug.println("ExceptionDialog.paint()");
  }

  public void actionPerformed(ActionEvent e)
  {
    if (e.getSource()==button_ok)
    {
       button_ok_action(e);
    }
    else if (e.getSource()==button_help)
    {
       button_help_action(e);
    }
  }

  public void button_ok_action(ActionEvent e)
  {
       dispose();
  }

  public void button_help_action(ActionEvent e)
  {
        HelpOS.setFile(current_url);
        HelpOS.openHelp();
  }



}

